package com.cd.card.domain;

import com.cd.common.domain.BaseDomain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.context.annotation.Primary;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import java.util.Date;

@Entity
@Data
@Table(name = "cd_card_inventory",
        indexes = {
                @Index(name = "user_id", columnList = "user_id"),
                @Index(name = "card_id", columnList = "card_id")
        },
        uniqueConstraints = {
        @UniqueConstraint(columnNames = {"user_id", "card_id"})
        })
@NoArgsConstructor
@AllArgsConstructor
public class Inventory extends BaseDomain {
//    inventory_id (Primary Key): 背包记录唯一标识符。
//    user_id : 关联到用户表的外键。
//    card_id : 关联到物品表的外键。
//    quantity: 物品数量。
//    slot_position: 在背包中的位置（如果背包有固定格数）。
//    acquired_time: 获取时间戳。

    @Id
    @GeneratedValue(strategy = javax.persistence.GenerationType.IDENTITY)
    @Column(name = "inventory_id", nullable = false)
    @Schema(title = "背包记录唯一标识符")
    private Long inventoryId;

    @Column(name = "user_id", nullable = false)
    @Schema(title = "关联到用户表的外键")
    private Long userId;

    @Column(name = "card_id", nullable = false)
    @Schema(title = "关联到物品表的外键")
    private Long cardId;

    @Column(name = "quantity", nullable = false)
    @Schema(title = "物品数量")
    private Long quantity;

//    @Column(name = "slot_position", nullable = false)
//    @Schema(title = "在背包中的位置（如果背包有固定格数）")
//    private Long slotPosition;

//    @Column(name = "acquired_time", nullable = false)
//    @Schema(title = "获取时间戳")
//    private Date acquiredTime;
}
